/*
 * 素材搜索
 * @Author: ljb
 * @Date: 2018-03-27 17:51:07
 * @Last Modified by: ljb
 * @Last Modified time: 2019-01-30 16:05:22
 */
<template>
	<Form
		ref="formInline"
		inline>

		<Form-item
			:label-width="100"
			:label="$t('tryon_material.category')"
			porp="material_type_id">
			<Select
				v-model="formValidate.category_id"
				clearable
				filterable
				transfer>
				<Option
					v-for="category in categories"
					:value="category.id + ''"
					:key="category.id">{{ category.name }}</Option>
			</Select>
		</Form-item>

		<Form-item
			:label-width="100"
			:label="$t('common.keyword')"
			prop="title">
			<i-input
				v-model="formValidate.keyword"
				:placeholder="$t('common.placeholder',{field: $t('common.keyword')})"
				type="text"/>
		</Form-item>

		<Form-item>
			<Button
				type="primary"
				@click="confirmSearch">{{ $t('common.search') }}</Button>
		</Form-item>

	</Form>
</template>
<script>

export default {

	name: 'MaterialSearchForm',

	props: {
		categories: {
			type: Array,
			default() {
				return [];
			},
		},
	},

	data() {
		return {

			formValidate: {

				category_id: '',

				keyword: '',

			}, // 搜索框的对象参数
		};
	},

	mounted() {

	},

	methods: {

		/**
         * 确认搜索
         * @return {undefined}
         */
		confirmSearch() {
			const param = {

				category_id: this.formValidate.category_id,

				keyword: this.formValidate.keyword,

			};

			this.$emit('search', param);
		},

	},

};

</script>
